<!--
  功能：离校审核
  作者：licy
  邮箱：licy@briup.com
  时间：2021年01月17日 09:56:15
  版本：v1.0
  修改记录：
  修改内容：
  修改人员：
  修改时间：
-->
<template>
  <div class=''>
    <!-- 按钮区域 -->
    <div class="btns">
      <div style="text-align:center">
        <el-form inline size="small">
          <el-form-item>
            <el-cascader filterable v-model="param.channelId" clearable :options="channels" placeholder="请选择渠道"
            :props="{ children:'children',label:'name',value:'id', emitPath: false}" ></el-cascader>
          </el-form-item>
          <el-form-item>
            <el-cascader filterable v-model="param.clazzId" clearable :options="directionClazzTree" placeholder="请选择班级"
          :props="{ children:'clazzes',label:'name',value:'id',emitPath: false}" ></el-cascader>
          </el-form-item>
          <el-form-item>
            <el-button @click="loadGraduateApply" icon="el-icon-search" type="primary" plain>搜索</el-button>
          </el-form-item>
        </el-form>
      </div>

    </div>
   
    <!-- 按钮区域结束 -->
    <!-- 表格 -->
    <el-table size="small" :data="applyData.list" v-loading="loading" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" fixed="left" > </el-table-column>
      <el-table-column label="序号" type="index" :index="1" fixed="left"></el-table-column>
      <el-table-column label="姓名" prop="student.realname" width="80" align="center" fixed="left"></el-table-column>
      <el-table-column label="入职公司名称" prop="companyName" width="200" align="center"> </el-table-column>
      <el-table-column label="入职公司地址" prop="companyAddress" width="260" align="center"> </el-table-column>
      <el-table-column label="岗位" prop="post" width="160" align="center"> </el-table-column>
      <el-table-column label="入职时间" prop="entryTime" width="120" align="center">
        <template slot-scope="scope">
          {{scope.row.entryTime | fmtDate}}
        </template>
      </el-table-column>
      <el-table-column label="申请时间" align="center" width="100"> 
        <template slot-scope="scope">
          {{scope.row.applyTime | fmtDate}}
        </template>
      </el-table-column>
      <el-table-column label="实习月薪" prop="salaryInternshipMonth" align="center" > </el-table-column>
      <el-table-column label="转正月薪" prop="salaryMonth" align="center" > </el-table-column>
      <el-table-column label="操作" width="120"  fixed="right" align="center">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="toCheckHandler(scope.row)">审核</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 表格结束 -->
    <!-- 分页 -->
   <div class="page">
      <el-pagination background 
        layout="prev, pager, next,sizes" 
        small
        :total="applyData.total" 
        :page-size="applyData.pageSize" 
        :current-page="applyData.page"
        :page-sizes="[ 15, 20,35,50]"
        @size-change="handleSizeChange"
        @current-change="currentChangeHandler">
      </el-pagination>
    </div>
    <!-- 分页 -->
    <!-- 抽屉 -->
    <Briupdrawer :drawer-visible="visible" :title="title" width="40%" @on-change-visible="handlerVisibleChange" >
      <div slot="content">
        <div class="apply_info">
          <div class="student_info" v-if="form.student">
            <div class="sub_title"> <em class="el-icon-user"></em> 学生基本信息</div>
            <div class="info_row">
              <div class="label">姓名</div>
              <div>{{form.student.realname}}</div>
            </div>
            <div class="info_row">
              <div class="label">班级</div>
              <div>{{form.student.clazz}}</div>
            </div>
          </div>
          <div class="info_row">
            <div class="label">离开原因</div>
            <div>{{form.leaveReason}}</div>
          </div>
          <div v-if="form.leaveReason == '已落实好工作'">
            <div class="sub_title"><em class="el-icon-goods"></em> 工作信息</div>
            <div class="info_row">
              <div class="label">单位名称</div>
              <div>{{form.companyName}}</div>
            </div>
            <div class="info_row">
              <div class="label">单位地址</div>
              <div>{{form.companyAddress}}</div>
            </div>
            <div class="info_row">
              <div class="label">单位联系人</div>
              <div>{{form.companyLinkName}}</div>
            </div>
            <div class="info_row">
              <div class="label">单位联系人电话</div>
              <div>{{form.companyLinkTelephone}}</div>
            </div>
            <div class="info_row">
              <div class="label">入职岗位</div>
              <div>{{form.post}}</div>
            </div>
            <div class="info_row">
              <div class="label">实习薪资福利</div>
              <div>{{form.salaryInternshipMonth}}</div>
            </div>
            <div class="info_row">
              <div class="label">转正薪资福利</div>
              <div>{{form.salaryMonth}}</div>
            </div>
          </div>

          <div v-if="form.leaveReason == '已考上研究生'">
            <div class="info_row">
              <div class="label">升学读研状态</div>
              <div>{{form.isGraduate}}</div>
            </div>
            <div class="info_row">
              <div class="label">报考学校、专业</div>
              <div>{{form.graduateCollege}}</div>
            </div>
          </div>

          <div v-if="form.leaveReason == '其他（非上述所列情况，申请离校）'">
            <div class="info_row">
              <div class="label">离校打算</div>
              <div>{{form.leavePlan}}</div>
            </div>
          </div>

          <div class="files">
            <div class="sub_title"><em class="el-icon-files"></em> 附件</div>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" type="danger" @click="submitCheckHandler('驳回')">驳回</el-button>
        <el-button size="small" type="primary" @click="submitCheckHandler('通过')">通过</el-button>
      </span>
    </Briupdrawer>
    <!-- 抽屉结束 -->
  </div>
</template>

<script>
import {get} from '@/utils/request'
import {mapGetters} from 'vuex';
export default {
  // 组件名称
  name: 'demo',
  // 组件参数 接收来自父组件的数据
  props: {},
  // 组件状态值
  data () {
   return {
     param:{},
     loading:false,
     param:{
        page:1,
        pageSize:15
     },
     applyData:{list:[]},
     visible:false,
     title:"离校申请审核",
     form:{},
     students:[]
   }
  },
  // 计算属性
  computed: {
     ...mapGetters(['channels','directionClazzTree','user']),
  },
  // 侦听器
  watch: {},
  // 组件方法
  methods: {
    // 去批量审核 
    toBatchCheckHandler (){

    },

    toCheckHandler(row){
      this.form = row;
      this.visible = true;
    },
    // 提交审核处理函数
    submitCheckHandler(status){
      
    },
    // 加载离校审核
    loadGraduateApply(){
      this.loading = true;
      let url = "/graduateApply/pageQuery"
      get(url,this.param).then(resp =>{
        this.applyData = resp.data;
        this.loading= false;
      })
    },
    // 处理visible变化的钩子函数，解决抽屉无法收缩的bug
    handlerVisibleChange(val) {
      this.visible = val
    },
    // 当前页发生改变
    currentChangeHandler(page){
      this.param.page = page;
      this.loadGraduateApply();
    },
    // 处理分页大小变化的函数
    handleSizeChange(pageSize){
      // 当前页为第一页
      this.page = 1;
      // 页面大小为用户选择的页面
      this.param.pageSize = pageSize;
      this.loadGraduateApply();
    },
    handleSelectionChange(val) {
      this.students = val;
    },
  },
  // 以下是生命周期钩子
  /**
  * 组件实例创建完成，属性已绑定，但DOM还未生成，$ el属性还不存在
  */
  created () {
    this.loadGraduateApply();
  },
  /**
  * el 被新创建的 vm.$ el 替换，并挂载到实例上去之后调用该钩子。
  * 如果 root 实例挂载了一个文档内元素，当 mounted 被调用时 vm.$ el 也在文档内。
  */
  mounted () {
  },
  /**
  * 实例销毁之前调用。在这一步，实例仍然完全可用。
  */
  beforeDestroy () {
  },
  /**
  * Vue 实例销毁后调用。调用后，Vue 实例指示的所有东西都会解绑定，
  * 所有的事件监听器会被移除，所有的子实例也会被销毁。
  */
  destroyed () {
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<!--使用了scoped属性之后，父组件的style样式将不会渗透到子组件中，-->
<!--然而子组件的根节点元素会同时被设置了scoped的父css样式和设置了scoped的子css样式影响，-->
<!--这么设计的目的是父组件可以对子组件根元素进行布局。-->
<style scoped lang="scss">
.apply_info {
  color: #666;
  font-size: 14px  !important;

  .info_row {
      line-height: 2em;
      display: flex;
      & > .label {
        width: 150px;
        text-align: right;
        padding:0 1em;
      }
      & > .label::after{
        content: "：";
      }
    }
}
</style>
